﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace ai_assignment_2
{
    class Program
    {
        static void Main(string[] args)
        {
            int N;
            Console.WriteLine("T for testcases or press any key to continue");
            if (Console.ReadLine().Equals("T"))
            {
                asserttest();
                return;
            }
            Console.WriteLine("Choose N");
            N = Convert.ToInt32(Console.ReadLine());

            choose(N);

        }
        public static void choose(int n)
        {
            int typeSearch = 0;
            do
            {
                Console.WriteLine("Enter search type");
                Console.WriteLine("1.DFS");
                Console.WriteLine("2.BFS");
                Console.WriteLine("3.BFS - Distance");
                Console.WriteLine("4.BFS - Mean distance");
                Console.WriteLine("5.BFS - Nr of open squares");
                Console.WriteLine("6.Min max");
                Console.WriteLine("7.Quit");
                typeSearch = Convert.ToInt32(Console.ReadLine());

                if (typeSearch == 1)
                    DFS(n);
                if (typeSearch == 2)
                    BFS(n);

            } while (typeSearch != 7);
        }

        public static void DFS(int n)
        {
            nQueen nqueen = new nQueen(n);
            int[] value = nqueen.placeNQueens("DFS");
            Console.WriteLine("Nr solutions :" + value[0] );
            Console.WriteLine("Nr states generated :" + value[1]);
        }
        public static void BFS(int n)
        {
            nQueen nqueen = new nQueen(n);
            int[] value = nqueen.placeNQueens("BFS");
            Console.WriteLine("Nr solutions :" + value[0]);
            Console.WriteLine("Nr states generated :" + value[1]);      
        }

        public static void asserttest()
        {
            Console.WriteLine("DFS test case from 4 - 8");
            
            nQueen queens4 = new nQueen(4);  // 2 possible solutions
            int[] value4DFS = queens4.placeNQueens("DFS");
            Debug.Assert(value4DFS[0] == 2, "Value4DFS is not 2");

            nQueen queens5 = new nQueen(5); // 10 possible solutions
            int[] value5DFS = queens5.placeNQueens("DFS");
            Debug.Assert(value5DFS[0] == 10, "Value5DFS is not 10");

            nQueen queens6 = new nQueen(6); // 4 possible solutions
            int[] value6DFS = queens6.placeNQueens("DFS");
            Debug.Assert(value6DFS[0] == 4, "Value6DFS is not 4");

            nQueen queens7 = new nQueen(7); // 40 possible solutions
            int[] value7DFS = queens7.placeNQueens("DFS");
            Debug.Assert(value7DFS[0] == 40, "Value7DFS is not 40");

            nQueen queens8 = new nQueen(8); // 92 possible solutions
            int[] value8DFS = queens8.placeNQueens("DFS");
            Debug.Assert(value8DFS[0] == 92, "Value7DFS is not 92");


            Console.WriteLine("BFS test case from 4 to 8");
            nQueen queens4BFS = new nQueen(4);  // 2 possible solutions
            int[] value4BFS = queens4BFS.placeNQueens("BFS");
            Debug.Assert(value4BFS[0] == 2, "Value4BFS is not 2");

            nQueen queens5BFS = new nQueen(5);  // 10 possible solutions
            int[] value5BFS = queens5BFS.placeNQueens("BFS");
            Debug.Assert(value5BFS[0] == 10, "Value5BFS is not 10");

            nQueen queens6BFS = new nQueen(6);  // 4 possible solutions
            int[] value6BFS = queens6BFS.placeNQueens("BFS");
            Debug.Assert(value6BFS[0] == 4, "Value5BFS is not 4");

            nQueen queenDist = new nQueen(4);
            int[] value4dist = queenDist.placeNQueens("Dist");        
        }
    }
}
